package Logic;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.JOptionPane;

import Messages.MeassageAddAssignment;
import Messages.MeassageAddBussiness;
import Messages.MeassageAddClient;
import Messages.MeassageAddDoor;
import Messages.MeassageAddLock;
import Messages.MeassageEditAssignment;
import Messages.MessageAddCoating;
import Messages.MessageAddEyepiece;
import Messages.MessageAddHandle;
import Messages.MessageAddLintel;
import Messages.MessageAddReservation;
import Messages.MessageAddStopwatch;
import Messages.MessageAddSuppliers;
import Messages.MessageAddUser;
import Messages.MessageAssignment;
import Messages.MessageBussinessClient;
import Messages.MessageClient;
import Messages.MessageCoating;
import Messages.MessageDeleteAssignment;
import Messages.MessageDeleteBussiness;
import Messages.MessageDeleteClient;
import Messages.MessageDeleteCoating;
import Messages.MessageDeleteDoor;
import Messages.MessageDeleteEyepiece;
import Messages.MessageDeleteHandle;
import Messages.MessageDeleteLintel;
import Messages.MessageDeleteLock;
import Messages.MessageDeleteReservation;
import Messages.MessageDeleteStopwatch;
import Messages.MessageDeleteSuppliers;
import Messages.MessageDeleteUser;
import Messages.MessageDoor;

import Messages.MessageEditBussinessClient;
import Messages.MessageEditClient;
import Messages.MessageEditCoating;
import Messages.MessageEditDoor;
import Messages.MessageEditEyepiece;
import Messages.MessageEditHandle;
import Messages.MessageEditLintel;
import Messages.MessageEditLock;
import Messages.MessageEditReservation;
import Messages.MessageEditStopwatch;
import Messages.MessageEditSuppliers;
import Messages.MessageEditUser;
import Messages.MessageEyepiece;
import Messages.MessageHandle;
import Messages.MessageLintel;
import Messages.MessageLock;
import Messages.MessageLogin;
import Messages.MessageOrderReport;
import Messages.MessageReservation;
import Messages.MessageStopwatch;
import Messages.MessageSuppliers;
import Messages.MessageUpdateAssignment;
import Messages.MessageUpdateBussinessClient;
import Messages.MessageUpdateClient;
import Messages.MessageUpdateCoating;
import Messages.MessageUpdateDoor;
import Messages.MessageUpdateEyepiece;
import Messages.MessageUpdateUser;
import Messages.MessageUser;

import Messages.MessageUpdateHandle;
import Messages.MessageUpdateLintel;
import Messages.MessageUpdateLock;
import Messages.MessageUpdateReservation;
import Messages.MessageUpdateStopwatch;
import Messages.MessageUpdateSuppliers;
import ocsf.server.ConnectionToClient;
/**
 * This class is the main class thats connect between the server and the client 
 * This class gets a msg and select the correct case and create a class that 
 * take an information from the DB 
 *  * @author Shlomit Yosfan
 * @author Nofar Sutliman
 */


public class TaskAssignment {
	
	ConnectionToClient client;
/**
 * This method gets an msg and selecting by the first word of the msg the correct case 	 
 * @param msg
 * @param client
 * @throws SQLException
 * @throws IOException
 */
	public TaskAssignment(Object msg, ConnectionToClient client) throws SQLException, IOException 
	{
		
		  String[] str;
		  msg= msg.toString().substring(1, msg.toString().length()-1); // remove the [] from the msg by substring 
		  str = msg.toString().split("[ , ] "); // remove the , from msg and splitting it to tiny str array parts  
		  
		  
		  switch(str[0])
	      {          
			      case ("Login"):
				  {
					
			    	  MessageLogin login =  new MessageLogin(str, client);  
			    	  login.Authorization();
					  
			      break;
				  }//end of case
			      case ("AddUser"):
				  {
					
			    	  MessageAddUser au =  new MessageAddUser(str, client);  
			    	  au.AddUser();
					  
			    	 
			      break;
				  }
			      case ("OrderReport"):
			      {	
			    	  
			    	  MessageOrderReport OrderReport =  new MessageOrderReport(str, client);  
			    	  OrderReport.OrderReport();
			    	  break;
			      }
			      
			      case ("AddAssignment"):
				  {
			    	  MeassageAddAssignment ass =  new MeassageAddAssignment(str, client);  
			    	  ass.AddAssignment();
				      break;

				  }
		
			      case ("AddLock"):
				  {
					
			    	  MeassageAddLock al =  new MeassageAddLock(str, client);  
			    	  al.AddLock();
					  
			      break;
				  }

			      case ("AddDoor"):
				  {
					
			    	  MeassageAddDoor ad =  new MeassageAddDoor(str, client);  
			    	  ad.AddDoor();
					  
			      break;
				  }
			      case ("AddLintel"):
				  {
					
			    	  MessageAddLintel ali =  new MessageAddLintel(str, client);  
			    	  ali.AddLintel();
					  
			      break;
				  }
			      case ("AddStopwatch"):
				  {
					
			    	  MessageAddStopwatch as =  new MessageAddStopwatch(str, client);  
			    	  as.AddStopwatch();
					  
			      break;
				  }
			      
			      case ("AddSuppliers"):
				  {
					
			    	  MessageAddSuppliers as =  new MessageAddSuppliers(str, client);  
			    	  as.AddSuppliers();
					  
			      break;
				  }
			      case ("AddHandle"):
				  {
					
			    	  MessageAddHandle ah =  new MessageAddHandle(str, client);  
			    	  ah.AddHandle();
					  
			      break;
				  }
			      case ("AddEyepiece"):
				  {
					
			    	  MessageAddEyepiece ae =  new MessageAddEyepiece(str, client);  
			    	  ae.AddEyepiece();
					  
			      break;
				  }
			      case ("AddCoating"):
				  {
					
			    	  MessageAddCoating ac =  new MessageAddCoating(str, client);  
			    	  ac.AddCoating();
					  
			      break;
				  }
			      case ("AddReservation"):
				  {
					
			    	  MessageAddReservation res =  new MessageAddReservation(str, client);  
			    	  res.AddReservation();
					  
			      break;
				  }
			      case ("AddBussiness"):
				  {
					
			    	  MeassageAddBussiness ab =  new MeassageAddBussiness(str, client);  
			    	  ab.AddBussiness();
					  
			      break;
				  }
			      case ("AddClient"):
				  {
					
			    	  MeassageAddClient res =  new MeassageAddClient(str, client);  
			    	  res.AddClient();
					  
			      break;
				  }
			      
			      case ("eyepiece"):
				  {
					
			    	  MessageEyepiece mep =  new MessageEyepiece(str, client);  
			    	  mep.SelectData();
					  
			      break;
				  }  
			      case ("Assignment"):
			         { 
			          
			    	  MessageAssignment Assignment =  new MessageAssignment(str, client);  
			          Assignment.SelectData();
			          break;
			         }
			      case ("lock"):
				  {
					
			    	  MessageLock mlo =  new MessageLock(str, client);  
			    	  mlo.SelectData();
					  
			      break;
				  }
			      
			      case ("handle"):
				  {
					
			    	  MessageHandle ha =  new MessageHandle(str, client);  
			    	  ha.SelectData();
					  
			      break;
				  }
			      case ("door"):
			      {
			    	  MessageDoor doo =  new MessageDoor(str, client);  
			    	  doo.SelectData();
					  
			      break;
				  }
			      
			      case ("coating"):
				  {
					
			    	  MessageCoating mco =  new MessageCoating(str, client);  
			    	  mco.SelectData();
					  
			      break;
				  }
			      
			      case ("lintel"):
				  {
			    	  MessageLintel mlin =  new MessageLintel(str, client);  
			    	  mlin.SelectData();	  
			      break;
				  }
			      
			      case ("stopwatch"):
				  {
			    	  MessageStopwatch msto =  new MessageStopwatch(str, client);  
			    	  msto.SelectData();  
			      break;
				  }
			      case ("User"):
				  {
					
			    	  MessageUser mu =  new MessageUser(str, client);  
			    	  mu.SelectData();
					  
			      break;
				  }
			      case ("DeleteEyepiece"):
			      {	
			    	  
			    	  MessageDeleteEyepiece DeleteEyepiece =  new MessageDeleteEyepiece(str, client);  
			    	  DeleteEyepiece.DeleteEyepiece();
			    	  break;
			      }
			      case ("DeleteLock"):
			      {	
			    	  
			    	  MessageDeleteLock DeleteLock =  new MessageDeleteLock(str, client);  
			    	  DeleteLock.DeleteLock();
			    	  break;
			      }
			      
			      case ("DeleteBussiness"):
			      {	
			    	  
			    	  MessageDeleteBussiness DeleteBussiness =  new MessageDeleteBussiness(str, client);  
			    	  DeleteBussiness.DeleteBussiness();
			    	  break;
			      }
			      case ("DeleteDoor"):
			      {	
			    	  
			    	  MessageDeleteDoor DeleteDoor =  new MessageDeleteDoor(str, client);  
			    	  DeleteDoor.DeleteDoor();
			    	  break;
			      }
			      case ("DeleteReservation"):
			      {	
			    	  
			    	  MessageDeleteReservation DeleteReservation =  new MessageDeleteReservation(str, client);  
			    	  DeleteReservation.DeleteReservation();
			    	  break;
			      }
			      case ("DeleteUser"):
			      {	
			    	  
			    	  MessageDeleteUser DeleteUser =  new MessageDeleteUser(str, client);  
			    	  DeleteUser.DeleteUser();
			    	  break;
			      }
			      case ("DeleteSuppliers"):
			      {	
			    	  
			    	  MessageDeleteSuppliers DeleteSuppliers =  new MessageDeleteSuppliers(str, client);  
			    	  DeleteSuppliers.DeleteSuppliers();
			    	  break;
			      }
			      
			      case ("DeleteAssignment"):
			         { 
			          
			    	  MessageDeleteAssignment DeleteAssignment =  new MessageDeleteAssignment(str, client);  
			          DeleteAssignment.DeleteAssignment();
			          break;
			         }
			      case ("Reservation"):
			      {	
			    	  
			    	  MessageReservation Reservation =  new MessageReservation(str, client);  
			    	  Reservation.View();
			    	  break;
			      }
			      
			      case ("Suppliers"):
			      {	
			    	  
			    	  MessageSuppliers Suppliers =  new MessageSuppliers(str, client);  
			    	  Suppliers.View();
			    	  break;
			      }
			      
			      case ("Client"):
			      {	
			    	  
			    	  MessageClient Client =  new MessageClient(str, client);  
			    	  Client.View();
			    	  break;
			      }
			      
			      case ("BussinessClient"):
			      {	
			    	  
			    	  MessageBussinessClient BussinessClient =  new MessageBussinessClient(str, client);  
			    	  BussinessClient.View();
			    	  break;
			      }
			      case ("DeleteLintel"):
			      {	
			    	  
			    	  MessageDeleteLintel DeleteLintel =  new MessageDeleteLintel(str, client);  
			    	  DeleteLintel.DeleteLintel();
			    	  break;
			      }
			      
			      
			      case ("DeleteStopwatch"):
			      {	
			    	  
			    	  MessageDeleteStopwatch DeleteStopwatch =  new MessageDeleteStopwatch(str, client);  
			    	  DeleteStopwatch.DeleteStopwatch();
			    	  break;
			      }
			      
			      case ("DeleteHandle"):
			      {	
			    	  
			    	  MessageDeleteHandle DeleteHandle =  new MessageDeleteHandle(str, client);  
			    	  DeleteHandle.DeleteHandle();
			    	  break;
			      
			      }
			      
			      case ("DeleteCoating"):
			      {	
			    	  
			    	  MessageDeleteCoating DeleteCoating =  new MessageDeleteCoating(str, client);  
			    	  DeleteCoating.DeleteCoating();
			    	  break;
			      
			      }
			      case ("DeleteClient"):
			      {	
			    	  
			    	  MessageDeleteClient DeleteClient =  new MessageDeleteClient(str, client);  
			    	  DeleteClient.DeleteClient();
			    	  break;
			      
			      }
		      
			      case ("EditLock"):
			         { 
			          
			          MessageEditLock EditLock =  new MessageEditLock(str, client);  
			          EditLock.EditLock();
			          break;
			         }
			         case ("EditAssignment"):
			         { 
			          
			        	 MeassageEditAssignment EditAssignment =  new MeassageEditAssignment(str, client);  
			          EditAssignment.EditAssignment();
			          break;
			         
			         }
			      case ("EditUser"):
			         { 
			          
			          MessageEditUser EditUser =  new MessageEditUser(str, client);  
			          EditUser.EditUser();
			          break;
			         
			         }
			      case ("UpdateUser"):
			         { 
			          
			          MessageUpdateUser UpdateUser =  new MessageUpdateUser(str, client);  
			          UpdateUser.UpdateUser();
			          break;
			         
			         }
			         case ("UpdateLock"):
			         { 
			          
			          MessageUpdateLock UpdateLock =  new MessageUpdateLock(str, client);  
			          UpdateLock.UpdateLock();
			          break;
			         
			         }
			         
			  
			         case ("UpdateAssignment"):
			         { 
			          
			        	 MessageUpdateAssignment UpdateAssignment =  new MessageUpdateAssignment(str, client);  
			        	 UpdateAssignment.UpdateAssignment();
			          break;
			         
			         }
			         
			          case ("EditDoor"):
			         { 
			          
			          MessageEditDoor EditDoor =  new MessageEditDoor(str, client);  
			          EditDoor.EditDoor();
			          break;
			         
			         }
			          
			       
			         case ("UpdateDoor"):
			         { 
			          
			          MessageUpdateDoor UpdateDoor =  new MessageUpdateDoor(str, client);  
			          UpdateDoor.UpdateDoor();
			          break;
			         
			         }   
  
			          case ("EditSuppliers"):
			         { 
			          
			          MessageEditSuppliers EditSuppliers =  new MessageEditSuppliers(str, client);  
			          EditSuppliers.EditSuppliers();
			          break;
			         
			         }
			          
				      case ("UpdateBussinessClient"):
				      { 
				          
				    	 MessageUpdateBussinessClient UpdateBussinessClient =  new MessageUpdateBussinessClient(str, client);  
				    	 UpdateBussinessClient.UpdateBussinessClient();
				          break; 
				         }
			         case ("UpdateSuppliers"):
			         { 
			          
			          MessageUpdateSuppliers UpdateSuppliers =  new MessageUpdateSuppliers(str, client);  
			          UpdateSuppliers.UpdateSuppliers();
			          break; 
			         }
			         
			         case ("UpdateClient"):
			         { 
			          
			         MessageUpdateClient UpdateClient =  new MessageUpdateClient(str, client);  
			          UpdateClient.UpdateClient();
			          break; 
			         }
			      
			         case ("EditClient"):
			         { 
			          
			        	 MessageEditClient EditClient =  new MessageEditClient(str, client);  
			          EditClient.EditClient();
			          break;
			         
			         }
			         
			         case ("EditBussinessClient"):
			         { 
			          
			          MessageEditBussinessClient EditBussinessClient =  new MessageEditBussinessClient(str, client);  
			          EditBussinessClient.EditBussinessClient();
			          break;
			         
			         }
			         
			         case ("EditEyepiece"):
			         { 
			          
			        	 MessageEditEyepiece EditEyepiece =  new MessageEditEyepiece(str, client);  
			          EditEyepiece.EditEyepiece();
			          break;
			         
			         }
			         case ("UpdateEyepiece"):
			         { 
			          
			        	 MessageUpdateEyepiece UpdateEyepiece =  new MessageUpdateEyepiece(str, client);  
			          UpdateEyepiece.UpdateEyepiece();
			          break;
			         
			         }  
			         case ("EditLintel"):
			         { 
			          
			          MessageEditLintel EditLintel =  new MessageEditLintel(str, client);  
			          EditLintel.EditLintel();
			          break;
			         
			         }
			         case ("UpdateLintel"):
			         { 
			          
			          MessageUpdateLintel UpdateLintel =  new MessageUpdateLintel(str, client);  
			          UpdateLintel.UpdateLintel();
			          break;
			         
			         }
			         case ("EditHandle"):
			         { 
			          
			          MessageEditHandle EditHandle =  new MessageEditHandle(str, client);  
			          EditHandle.EditHandle();
			          break;
			         
			         }
			         case ("UpdateHandle"):
			         { 
			          
			          MessageUpdateHandle UpdateHandle =  new MessageUpdateHandle(str, client);  
			          UpdateHandle.UpdateHandle();
			          break;
			         
			         }  
			         case ("EditCoating"):
			         { 
			          
			          MessageEditCoating EditCoating =  new MessageEditCoating(str, client);  
			          EditCoating.EditCoating();
			          break;
			         
			         }
			         case ("UpdateCoating"):
			         { 
			          
			          MessageUpdateCoating UpdateCoating =  new MessageUpdateCoating(str, client);  
			          UpdateCoating.UpdateCoating();
			          break;
			         
			         }    
			         case ("EditReservation"):
			         { 
			          
			          MessageEditReservation EditReservation =  new MessageEditReservation(str, client);  
			          EditReservation.EditReservation();
			          break;
			         
			         }
			         case ("UpdateReservation"):
			         { 
			          
			          MessageUpdateReservation UpdateReservation =  new MessageUpdateReservation(str, client);  
			          UpdateReservation.UpdateReservation();
			          break;
			         
			         }  
			         case ("EditStopwatch"):
		             { 
		              
		              MessageEditStopwatch EditStopwatch =  new MessageEditStopwatch(str, client);  
		              EditStopwatch.EditStopwatch();
		              break;
		             }
			         case ("UpdateStopwatch"):
		             { 
		              
		              MessageUpdateStopwatch UpdateStopwatch =  new MessageUpdateStopwatch(str, client);  
		              UpdateStopwatch.UpdateStopwatch();
		              break;
		             
		             }
			      
	      }//end of switch
		  
		  
		  
	}}//end of TaskAssignment





	